#include "stdafx.h"
#include "./glPictLabel.h"
#include "./glPict.h"
#include "./glPainter.h"

GLES::Bool GLES::PictLabel::createFrom( Pict* pict,PointI& point,SizeI& size,RectI* pictRect /*= NULL*/,Bool pictDestroy )
{
	_pict = pict;
	_point = point;
	_size = size;
	_Destroy = pictDestroy;
	if(pictRect)
		_pictRect = *pictRect;
	else
		_pictRect.set(0,0,1,1);
	return true;
}

GLES::Bool GLES::PictLabel::createFrom( char* name,PointI& point,SizeI* size,RectI* pictRect /*= NULL*/ )
{
	
	_pict = new Pict();
	E_Return(_pict->createFromPVR(name));
	_Destroy = true;
	_point = point;
	_size = size ? *size : _pict->getSize();

	if(pictRect)
		_pictRect = *pictRect;
	else
		_pictRect.set(0,0,1,1);
	return true;
}

GLES::Void GLES::PictLabel::draw( Painter* painter )
{
	painter->drawPict(RectI(_point.x,_point.y,_point.x + _size.w,_point.y + _size.h),_pict);
}

GLES::PictLabel::PictLabel() :_Destroy(false),_pict(NULL)
{

}

GLES::PictLabel::~PictLabel()
{
	if(_Destroy)SAFE_DELETE(_pict);
}

GLES::Void GLES::PictLabel::movePosition( Vector2I& vect )
{
	_point.x += vect.x;
	_point.y += vect.y;
}